<?php

namespace app\models;

use Yii;
use yii\db\Query;
/**
 * This is the model class for table "{{%sys_user_log}}".
 *
 * @property integer $id
 * @property integer $uid
 * @property string $operation
 * @property string $remark
 * @property string $ip
 * @property integer $create_time
 */
class SysUserLog extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%sys_user_log}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['uid', 'operation'], 'required'],
            [['uid', 'create_time'], 'integer'],
            [['operation', 'remark'], 'string', 'max' => 120],
            [['ip'], 'string', 'max' => 30]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'uid' => 'Uid',
            'operation' => 'Operation',
            'remark' => 'Remark',
            'ip' => 'Ip',
            'create_time' => 'Create Time',
        ];
    }
    
    public function includeAll($uid){
        $include = (new Query())->select("*")->from("dh_sys_users")->where(["parent_id"=>$uid])->all();
        $tag = [];
        $tag[0] =  $uid;
        foreach ($include as $value) {
            $tag[] = $value['id'];
        }
//        print_r($tag);die();
        return $tag;
    }
}
